<%--<security:authorize ifAnyGranted="ROLE_DEALER_USER">
  <c:if test="${loanRequest.dealerUser.username==pageContext.request.remoteUser and (loanRequest.phase=='ca_audit' or loanRequest.phase=='sca_audit' or loanRequest.phase=='booking_audit')}">
    <c:set var="feedbackEnabled" scope="page" value="true" />
  </c:if>
</security:authorize>
<security:authorize ifAnyGranted="ROLE_Bank_RECEIVER">
    <c:if test="${!loanRequest.received}">
        <c:set var="feedbackEnabled" scope="page" value="true" />
    </c:if>
</security:authorize>
<security:authorize ifAnyGranted="ROLE_SCA">
  <c:if test="${loanRequest.phase=='qualification_audit'}">
    <c:set var="feedbackEnabled" scope="page" value="true" />
  </c:if>
</security:authorize>
<security:authorize ifAnyGranted="ROLE_Booking">
  <c:if test="${loanRequest.phase=='bank_loan_audit' or loanRequest.phase=='insurance_loan_audit'}">
    <c:set var="feedbackEnabled" scope="page" value="true" />
  </c:if>
</security:authorize>
<c:if test="${loanRequest.auditUser.username==pageContext.request.remoteUser and (loanRequest.phase=='ca_audit' or loanRequest.phase=='sca_audit' or loanRequest.phase=='booking_audit')}">
  <c:set var="feedbackEnabled" scope="page" value="true" />
</c:if>
<c:if test="${(loanRequest.auditUser.username==pageContext.request.remoteUser || loanRequest.dealer.masterProvider.bondUser.username==pageContext.request.remoteUser)
    and (loanRequest.phase=='qualification_audit' or loanRequest.phase=='bank_loan_audit' or loanRequest.phase=='insurance_loan_audit')}">
  <c:set var="feedbackEnabled" scope="page" value="true" />
</c:if>--%>

<div class="box box-primary">
  <div class="box-header  with-border">
    <h3 class="box-title"><fmt:message key="feedbackList.feedback"/>
        <%--<small>(<span id="feedbackType" style="font-weight: bold; color:dodgerblue"><fmt:message key="FEEDBACK_STATUS_${loanRequest.feedbackType}"/></span>)</small>--%>
        <c:if test="${feedbackInfo != null}">
          &nbsp;<a  class="btn btn-primary btn-xs margin" id="open-feedback"> <i class="fa fa-plus"></i><fmt:message key="feedback.request"/></a>
        </c:if>
    </h3>
    <div class="box-tools pull-right">
      <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
    </div>
  </div>
  <!-- /.box-header -->
  <div class="box-body" style="height: 200px;overflow-y:auto;">
    <table class="table table-condensed" id="feedbackList">
      <thead>
      <tr>
        <th><fmt:message key="feedback.time"/></th>
        <th><i class="fa fa-user"></i></th>
        <th><fmt:message key="feedback.content"/></th>
        <th><fmt:message key="feedback.type"/></th>
          <th>#</th>
      </tr>
      </thead>
      <tbody>
      <c:forEach var="feedback" items="${loanRequest.feedbackList}">
        <tr>
          <td><fmt:formatDate value="${feedback.time}" pattern="${datePattern}"/></td>
          <td>${feedback.feedbackRequester.name}</td>
          <td class="feedbackContent" title="${fn:length(feedback.content) > 10 ? feedback.content : ''}">${fn:length(feedback.content) > 10 ? fn:substring(feedback.content,0,10) : feedback.content} ${fn:length(feedback.content) > 10 ? '...' : ''}</td>
          <td><fmt:message key="FEEDBACK_TYPE_${feedback.feedbackType}"/></td>
            <td><c:if test="${feedback.requireBack && feedback.feedbackTarget.username==pageContext.request.remoteUser && feedback.feedbackStatus=='Requested'}"><a id="${feedback.id}" class="needReply" title="<fmt:message key="feedback.reply"/>"><i class="fa fa-reply"></i></a></c:if>
            <c:if test="${feedback.feedbackStatus=='Returned' && feedback.feedbackRequester.username!=pageContext.request.remoteUser}"><fmt:message key="FEEDBACK_STATUS_Returned"/></c:if>
                <c:if test="${((!feedback.requireBack && feedback.feedbackTarget.username==pageContext.request.remoteUser) || (feedback.feedbackStatus=='Returned'&& feedback.feedbackRequester.username==pageContext.request.remoteUser)) && feedback.feedbackStatus!='End'}"><a id="${feedback.id}" class="markRead"><i class="fa fa-check"></i></a></c:if>

            </td>
        </tr>
      </c:forEach>
      </tbody>
    </table>

  </div>
    <div class="overlay" id="feedbackOverlay" style="display: none">
        <i class="fa fa-refresh fa-spin"></i>
    </div>
</div>
<div id="feedback" title="<fmt:message key="feedbackList.feedback"/>">
    <form class="form">
        <div class="form-group">
            <fmt:message key="feedback.content"/>
            <textarea rows="4" id="feedbackContent" class="form-control" name="content"></textarea>
        </div>
        <div class="form-group">
            <fmt:message key="feedback.type"/>
            <security:authorize ifNotGranted="ROLE_M_RECEIVE">
            <div class="radio">
                <label>
                    <input type="radio" name="feedbackType" value="MessageType" checked="">
                    <fmt:message key="FEEDBACK_TYPE_MessageType"/>
                </label>
            </div>
            <div class="radio">
                <label>
                    <input type="radio" name="feedbackType" value="MaterialType">
                    <fmt:message key="FEEDBACK_TYPE_MaterialType"/>
                </label>
            </div>
            </security:authorize>
        <security:authorize ifAnyGranted="ROLE_DEALER_USER,ROLE_M_RECEIVE">
            <div class="radio">
                <label>
                    <input type="radio" name="feedbackType" value="FileRecAndSend">
                    <fmt:message key="FEEDBACK_TYPE_FileRecAndSend"/>
                </label>
            </div>
            </security:authorize>
        </div>
        <div class="form-group">
            <fmt:message key="feedback.requireBack"/>
            <input type="checkbox" id="requireBack" <c:if test="feedbackInfo.requireRespond"> checked="checked" </c:if> />
        </div>

        <a class="btn btn-default" id="saveFeedback"><fmt:message key="button.save"/></a>
    </form>

</div>
<div id="feedbackReply" title="<fmt:message key="feedback.reply"/>">
    <form class="form">
        <input type="hidden" id="replyFeedBack"/>
        <div class="form-group">
            <fmt:message key="feedback.content"/>
            <textarea rows="4" id="feedbackContentOrg" class="form-control" name="content" disabled></textarea>
        </div>
        <div class="form-group">
            <fmt:message key="feedback.reply"/>
            <textarea rows="4" id="feedbackContentNew" class="form-control" name="content"></textarea>
        </div>

        <a class="btn btn-default" id="saveFeedbackReply"><fmt:message key="button.save"/></a>
    </form>

</div>